home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr29 / fm2_227.zip / EXAMPLE.CMD < prev    next >
OS/2 REXX Batch file  |  1995-02-26  |  1KB  |  53 lines

  1. /*
  2.  * Example of how a rexx file can operate on a list file created by
  3.  * FM/2 (the list file should contain filenames only).
  4.  */
  5.  
  6. /* get name of listfile from command line */
  7. parse arg listfile
  8. /* if no listfile name was given, issue help and exit */
  9. if listfile = '' then
  10. do
  11.   say 'Give the name of a listfile as an argument to this REXX script.'
  12.   exit
  13. end
  14. /* see if the listfile given exists -- exit with error message if not */
  15. rc = stream(listfile,'C','QUERY EXISTS')
  16. if rc = '' then
  17. do
  18.   say "File "listfile" doesn't exist."
  19.   exit
  20. end
  21. /* attempt to open the listfile given on the command line */
  22. rc = stream(listfile,'C','OPEN')
  23. /* if open was successful, enter loop */
  24. if rc = 'READY:' then
  25. do
  26.   counter = 0     /* initialize counter */
  27.   /* read each line of the listfile into filename */
  28.   do while lines(listfile) = 1
  29.     filename = linein(listfile)
  30.     /* remove any leading/trailing blanks */
  31.     filename = strip(filename,'b')
  32.     /* process only non-blank strings */
  33.     if filename \= '' then
  34.     /*
  35.      * here you would do something to/with the file in filename
  36.      * since this is just an example, we'll just print the name
  37.      */
  38.     do
  39.       say filename
  40.       counter = counter + 1 /* count files processed */
  41.     end
  42.   end
  43.   /* close the listfile */
  44.   rc = stream(listfile,'C','CLOSE')
  45. end
  46. else
  47. do
  48.   say 'Error opening 'listfile'.'
  49.   exit
  50. end
  51. /* we're done */
  52. say '  **We processed 'counter' files.'
  53.